package com.shanghai.shanghaielectric.UI.basefragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

/**
 * Created by admin on 2018/1/9.
 */

public abstract class TabFragment extends BaseFragment {

    protected ViewGroup mContentView;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        if (mContentView == null || !isRetainContent()) {
            mContentView = (ViewGroup) inflater.inflate(getLayoutResId(), null);
            onCreateContentView(mContentView, savedInstanceState);
        }
        return mContentView;
    }

    protected abstract void onCreateContentView(View contentView, Bundle savedInstanceState);

    protected abstract int getLayoutResId();

    protected boolean isRetainContent() {
        return true;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        if (!isRetainContent()) {
            mContentView = null;
        }
    }

    public void onTabChanged(int position) {

    };

}

